cmake_minimum_required(VERSION 3.1)
project(test_package C)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup(TARGETS)

option(OPENSSL_WITH_ZLIB "OpenSSL with zlib support" ON)
option(OPENSSL_WITH_LEGACY "OpenSSL with support for the legacy provider" ON)
option(OPENSSL_WITH_MD4 "OpenSSL with MD4 support (needs legacy provider)" ON)
option(OPENSSL_WITH_RIPEMD160 "OpenSSL with RIPEMD16 support (needs legacy provider)" ON)

set(OpenSSL_DEBUG 1)
find_package(OpenSSL REQUIRED)

message("OPENSSL_FOUND: ${OPENSSL_FOUND}")
message("OPENSSL_INCLUDE_DIR: ${OPENSSL_INCLUDE_DIR}")
message("OPENSSL_CRYPTO_LIBRARY: ${OPENSSL_CRYPTO_LIBRARY}")
message("OPENSSL_CRYPTO_LIBRARIES: ${OPENSSL_CRYPTO_LIBRARIES}")
message("OPENSSL_SSL_LIBRARY: ${OPENSSL_SSL_LIBRARY}")
message("OPENSSL_SSL_LIBRARIES: ${OPENSSL_SSL_LIBRARIES}")
message("OPENSSL_LIBRARIES: ${OPENSSL_LIBRARIES}")
message("OPENSSL_VERSION: ${OPENSSL_VERSION}")

add_executable(digest digest.c)
if(OPENSSL_WITH_ZLIB)
    target_compile_definitions(digest PRIVATE WITH_ZLIB)
endif()
target_link_libraries(digest OpenSSL::Crypto)

if(OPENSSL_WITH_LEGACY)
    add_executable(digest_legacy digest_legacy.c)
    # do now show deperecation warnings
    target_compile_definitions(digest_legacy PRIVATE OPENSSL_SUPPRESS_DEPRECATED)
    if(OPENSSL_WITH_MD4)
      target_compile_definitions(digest_legacy PRIVATE OPENSSL_WITH_MD4)
    endif()
    if(OPENSSL_WITH_RIPEMD160)
      target_compile_definitions(digest_legacy PRIVATE OPENSSL_WITH_RIPEMD160)
    endif()
    if(OPENSSL_WITH_ZLIB)
        target_compile_definitions(digest_legacy PRIVATE WITH_ZLIB)
    endif()
    target_link_libraries(digest_legacy OpenSSL::Crypto)
endif()
